package ${packageName};

<%
if (hasDateType) {
    println("import java.util.Date;");
}
%>
import java.util.Objects;

/**
 * This is the model class for ${tableName}
 */
public class ${className} {

    <%
    for (field in fields) {
        println("    private " + field.type + " " + field.name + "; // " + field.columnName);
        println();
    }
    for (field in fields) {
        println("    public void " + field.setterName + "(" + field.type + " " + field.name + ") {");
        println("        this." + field.name + " = " + field.name + ";");
        println("    }");
        println();
        println("    public " + field.type + " " + field.getterName + "() {");
        println("        return this." + field.name + ";");
        println("    }");
        println();
    }
    %>

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("${className} {");
        <%
        for (field in fields) {
            if (fieldLP.last) {
                println("        sb.append(\"" + field.name + "='\").append(" + field.name + ").append(\"\\'\");");
            } else {
                println("        sb.append(\"" + field.name + "='\").append(" + field.name + ").append(\"\\'; \");");
            }
        }
        %>
        sb.append('}');
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ${className} thisOne = (${className}) o;
        <%
        for (field in fields) {
            if (fieldLP.first) {
                println("        return Objects.equals(" + field.name + ", thisOne." + field.name + ") &&");
            } else if (fieldLP.last) {
                println("            Objects.equals(" + field.name + ", thisOne." + field.name + ");");
            } else {
                println("            Objects.equals(" + field.name + ", thisOne." + field.name + ") &&");
            }
        }
        %>
    }

    @Override
    public int hashCode() {
        <%
        for (field in fields) {
            if (fieldLP.first) {
                print("        return Objects.hash(" + field.name + ", ");
            } else if (fieldLP.last) {
                println(field.name + ");");
            } else {
                print(field.name + ", ");
            }
        }
        %>
    }

}